/***
    Amrita ITEWS - Copyright (C) 2009 Amrita Vishwa Vidyapeetham, Amritapuri.
                                       (http://www.amrita.edu)
    ***************************************************************************
    This file is part of the Amrita ITEWS distribution.
    Amrita ITEWS is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License (version 2) as published
    by the Free Software Foundation AND MODIFIED BY the Amrita ITEWS exception.
    ***NOTE*** The exception to the GPL is included to allow you to distribute
    a combined work that includes Amrita ITEWS without being obliged to provide
    the source code for proprietary components outside of the Amrita ITEWS
    software. Amrita ITEWS is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
    Public License for more details. You should have received a copy of the GNU
    General Public License and the Amrita ITEWS license exception along with
    Amrita ITEWS if not then it can be viewed here:
    http://itews.amrita.ac.in/license.html.


    Documentation, latest information, license and contact details are at:
    http://itews.amrita.ac.in/


    Amrita ITEWS source code can be found at:
    http://code.google.com/p/itews


    The initial code-base of Amrita ITEWS was developed by Amrita Vishwa
    Vidyapeetham as part of the project titled,"Intelligent & Interactive
    Telematics using Emerging Wireless Technologies for Transport Systems
    (ITEWS)" sponsored by Technology Information Forecasting and Assessment
    Council (TIFAC), India.
***/

/*! \file dgram_eventq.h
    \brief UDP Datagram Event Queue Service Provider Interface Header File.
*/

#ifndef DGRAM_EVENTQ_H_
#define DGRAM_EVENTQ_H_

#include <eventq.h>

/*! \brief  Maximum Size of UDP Data Received.*/
#define     DGRAM_UDP_DATA_MAXSZ    1024

/*! \brief Create Server Socket (Bind) Event Type Flag
 PUT event,
 param (I) - address of dgram_param_t which contains port to bind,
 buf - none.
 */
#define     EVT_DGRAM_BIND          0x00

/*! \brief Socket Send Data Event Type Flag
 PUT event,
 param -  address of the dgram_parameter_t which contains the the remote IP and port.
 buf (I) - data to be send.
 */
#define     EVT_DGRAM_PUT_DATA      0x01

/*! \brief Socket Receive Data Event Type Flag
 GET event,
  param (O) - address of dgram_param_t to which remote IP,
   port is returned,
  buf (O) - buffer to which data has to be read
  (must be allocated by the caller).
  */
#define     EVT_DGRAM_GET_DATA      0x02

/*! \brief Maximum Size in Bytes of IP Address String.*/
#define     DGRAM_MAX_IPSTR_SZ      16

/*! \brief Datagram Event Queue Operation Structure Global Variable.*/
extern eventq_ops_t dgram_eventq_ops;

/*! \brief Datagram Event Param Structure.*/
typedef struct
{
    /*! \brief IP Address for Event Manipulation.*/
    int8 ip[ DGRAM_MAX_IPSTR_SZ ];

    /*! \brief Port Number for Event Manipulation.*/
    uint16 port;
}dgram_param_t;

/*SPI*/
STATUS dgram_eventq_open        ( eventq_ctx_t *, const char *eventq_name );
STATUS dgram_eventq_close       ( eventq_ctx_t * );
STATUS dgram_eventq_sync_put    ( eventq_ctx_t *, event_t *, HRESULT *res );
STATUS dgram_eventq_sync_get    ( eventq_ctx_t *, event_t * );

#endif /*DGRAM_EVENTQ_H_*/
